<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改source')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-source-edit" th:object="${mcGlDbSource}">
            <input name="keyId" th:field="*{keyId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">编码：</label>
                <div class="col-sm-8">
                    <input name="codeSource" th:field="*{codeSource}" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">名称：</label>
                <div class="col-sm-8">
                    <input name="nameSource" th:field="*{nameSource}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">软件名称：</label>
                <div class="col-sm-8">
                    <input name="nameSoft" th:field="*{nameSoft}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">软件版本：</label>
                <div class="col-sm-8">
                    <input name="nameVer" th:field="*{nameVer}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库类型：</label>
                <div class="col-sm-8">
                    <input name="databaseType" th:field="*{databaseType}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库名称：</label>
                <div class="col-sm-8">
                    <input name="databaseName" th:field="*{databaseName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库版本：</label>
                <div class="col-sm-8">
                    <input name="databaseVer" th:field="*{databaseVer}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库IP：</label>
                <div class="col-sm-8">
                    <input name="databaseIp" th:field="*{databaseIp}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">数据库端口：</label>
                <div class="col-sm-8">
                    <input name="databasePort" th:field="*{databasePort}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库用户：</label>
                <div class="col-sm-8">
                    <input name="databaseUser" th:field="*{databaseUser}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数据库密码：</label>
                <div class="col-sm-8">
                    <input name="databasePwd" th:field="*{databasePwd}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="BZ" th:field="*{BZ}" class="form-control" type="text">
                </div>
            </div>
        </form>
        <div class="form-group">
            <div class="col-sm-9">

            </div>
            <div class="col-sm-3">
                <a class="btn btn-success" onclick="testConnect()" >
                    连接测试
                </a>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/source";
        $("#form-source-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-source-edit').serialize());
            }
        }

        function testConnect() {
            let data = $('#form-source-edit').serialize();
            var config = {
                url: prefix + "/dbConnectTest",
                type: "post",
                dataType: "json",
                data: data,
                success: function(result) {
                    if(result.code==0){
                        $.modal.alertSuccess(result.msg);
                    }
                    else{
                        $.modal.alertError(result.msg);
                    }
                }
            };
            $.ajax(config)
        }
    </script>
</body>
</html>